﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Index2.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<App.Views.ViewModels.UCServicesItemListViewModel>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
整理服务
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        var id = 'CosmeticNO';
        var ctrlName = 'CosmeticService';
        function Crud2(id, ctrlName) {
            Crud.call(this, id, ctrlName);
            this.Create = function () {
                url = '../' + ctrlName + '/Create';
                this.url = url;
                $('#dlg').dialog({                    
                    onBeforeOpen: function () {
                        $('#itemList').load(url);
                    }
                });
                $('#dlg').dialog('open').dialog('setTitle', '新增');
                $('#fm').form('clear');
                var curTime = new Date().Format('yyyy-MM-dd hh:mm:ss');
                $('#fm').form('load', { 'EndTime': curTime, 'StartTime':curTime });
            };
            this.Edit = function () {
                var row = $('#dg').datagrid('getSelected');
                if (row) {
                    var curTime = (new Date()).getTime();
                    url = '../' + ctrlName + '/Edit?id=' + row[id] + "&s=" + curTime;
                    url = encodeURI(url);                  
                    this.url = url;
                    $('#dlg').dialog({
                        onBeforeOpen: function () {
                            $('#itemList').load(url);
                        }
                    });
                    $('#dlg').dialog('open').dialog('setTitle', '修改');
                    row['StartTime'] = JsonToDateString(row['StartTime'], 'yyyy-MM-dd hh:mm:ss');
                    row['EndTime'] = JsonToDateString(row['EndTime'], 'yyyy-MM-dd hh:mm:ss');
                    $('#fm').form('load', row);
                } else {
                    $.messager.alert("提示", "请选择一条记录进行编辑!");
                }
            };
        }

        var crud = new Crud2(id, ctrlName);
        $(function () {
            //选择整容师
            $('#Beautician').click(function () {
                $.ajaxSetup({ cache: false });                
                var st = $('[name="StartTime"]').val();
                var et = $('[name="EndTime"]').val();
                var url = '../' + ctrlName + '/SelectBeautician?st=' + st + '&et=' + et;
                url = encodeURI(url);
                $('#dlgBeauticianList').dialog({
                    modal: true,
                    width: 450,
                    height: 300,
                    inline: true,
                    title: '选择整容师',
                    onBeforeOpen: function () {
                        $('#dvList').load(url);
                    },
                    toolbar: [{
                        id: 'btnOk',
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: function () {
                            var items = $(':radio:checked');
                            if (items.length > 0) {
                                $('#Beautician').val(items[0].value);
                            }
                            $('#dlgBeauticianList').dialog('close');
                        }
                    }]
                });
                $('#dlgBeauticianList').dialog('open');
            });
            $('#dg').datagrid({
                title: '整理服务列表',
                iconCls: 'icon-save',
                url: '../' + ctrlName + '/List',
                sortName: id,
                sortOrder: 'asc',
                remoteSort: false,
                idField: id,
                frozenColumns: [[
	                { field: 'ck', checkbox: true },
	                { title: '编号', field: id, width: 80, sortable: true }
				]],
                columns: [[
                        { field: 'ServiceNo', title: '服务编号', width: 80 },
                        { field: 'Beautician', title: '整容师', width: 100 },
                        { field: 'StartTime', title: '开始时间', width: 150,
                            formatter: function (value) {
                                return JsonToDateString(value, 'yyyy-MM-dd hh:mm:ss');
                            }
                        },
                        { field: 'EndTime', title: '结束时间', width: 150,
                            formatter: function (value) {
                                return JsonToDateString(value, 'yyyy-MM-dd hh:mm:ss');
                            }
                        }
                    ]],
                pagination: true,
                fitColumns: true,
                toolbar: toolbar
            });
        });      
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
     <div id="dlg" class="easyui-dialog" closed="true" buttons="#dlg-buttons" 
			style="width:580px;height:450px;padding:5px 5px">
		<div class="ftitle">整理服务信息</div>
		<form id="fm" method="post">            
			<table width="100%">
                <tr>
                    <td width="80" align="right">编号</td>
                    <td><input id="ServiceNo" name="ServiceNo" readonly="readonly" class="easyui-validatebox readonly"  />
                        <input id="CosmeticNO" name="CosmeticNO" type="hidden" />
                    </td> 
                    <td  width="80" align="right">死者编号</td>
                    <td><input id="DeadNO" name="DeadNO" class="easyui-validatebox" /></td>                                                           
                </tr>                
                <tr>
                    <td align="right">开始时间</td>
                    <td><input class="easyui-datetimebox readonly" readonly="readonly" id="StartTime" name="StartTime" required="true" style="width:150px"/> </td>
                    <td align="right">结束时间</td>
                    <td><input class="easyui-datetimebox readonly" readonly="readonly" id="EndTime" name="EndTime" required="true" style="width:150px"/> </td>                
                </tr>   
                <tr>
                    <td width="80" align="right">选择整容师</td>
                    <td colspan="3" ><input id="Beautician" name="Beautician"  class="easyui-validatebox " /></td>                                        
                </tr>                             
                <tr>
                    <td colspan="4">
                        <div id="itemList">
                            <%Html.RenderPartial("UCServicesItemList", Model);%>
                        </div>                                           
                    </td>
                </tr>
            </table>             
		</form> 
        <div id="dlgBeauticianList">
            <div id="dvList"></div>
        </div>               
        <!-- 选择死者列表 -->
        <% Html.RenderPartial("UCSelectDeadNo"); %>
	</div>
</asp:Content>


